package phone.example.com.a36kr.adapter;

import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

import phone.example.com.a36kr.R;
import phone.example.com.a36kr.bean.LocalBean;
import phone.example.com.a36kr.bean.UserBean;
import phone.example.com.a36kr.nettool.NetTool;
import phone.example.com.a36kr.tools.BaseActivity;

/**
 * Created by dllo on 16/8/30.
 */
public class CollectLvAdapter extends BaseAdapter {

    private Context mContext;

    private ArrayList<LocalBean> localBeen;

    public CollectLvAdapter(Context mContext) {
        this.mContext = mContext;
        notifyDataSetChanged();
    }



    public void setLocalBeen(ArrayList<LocalBean> localBeen) {
        this.localBeen = localBeen;

    }

    @Override
    public int getCount() {
        return localBeen != null ? localBeen.size() : 0;
    }


    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        LayoutInflater inflater = LayoutInflater.from(mContext);
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.items_collect_lv, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        NetTool netTool = new NetTool();
        netTool.getImage(localBeen.get(position).getIcon(), viewHolder.iconIv);
        viewHolder.titleTv.setText(localBeen.get(position).getTitle());
        //viewHolder.columnName.setText(localBeen.get(position).getColumnName());
        viewHolder.writer.setText(localBeen.get(position).getWriter());

        return convertView;



    }
    public class ViewHolder {
        private  ImageView iconIv;
        private  TextView titleTv;
        private  TextView writer;
        private  TextView columnName;

        public ViewHolder(View convertView) {
            iconIv = (ImageView) convertView.findViewById(R.id.items_collect_icon);
            titleTv = (TextView) convertView.findViewById(R.id.items_collect_title);
            writer = (TextView) convertView.findViewById(R.id.items_collect_name);
            columnName = (TextView) convertView.findViewById(R.id.items_news_columnNameTV);

        }
    }

}


